package com.dxd.security.controller;

import com.dxd.security.model.User;
import com.dxd.security.vo.request.UserParam;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
@Api(description = "用户管理")
public class UserController {

    @GetMapping()
    @ApiOperation("查询用户集合")
    @JsonView(User.JSONSimpleViews.class)
    public List<User> getUser(UserParam username){
        System.out.println(ReflectionToStringBuilder.toString(username));
        List<User> list = new ArrayList<>();
        list.add(new User());
        list.add(new User());
        list.add(new User());

        return list;
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "查询用户")
    @JsonView(User.JSONDetailViews.class)
    public User getUserInfo(@ApiParam("用户ID")@PathVariable String id){
        User user = new User();
        user.setUsername("tom");
        return user;
    }

}
